package com.xw.controller.api;

import com.xw.service.tool.oss.OssTransCodeService;
import com.xw.util.JsonData;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.io.IOException;
import java.util.Map;

@Controller
@RequestMapping("/api/oss/")
@Scope("prototype")
public class ApiOssController {
    @Resource
    private OssTransCodeService ossTransCodeService;

    /**
     * Oss视频转码
     * ossInputObject  源文件（oss返回的相对路径）
     * ossOutputObject 转码后的文件 不需要后缀名（也是相对路径）
     */
    @RequestMapping(value = "simpleTranscode", method = RequestMethod.POST)
    @ResponseBody
    public Object simpleTranscode(String ossInputObject, String ossOutputObject) throws IOException {
        Map map =  ossTransCodeService.simpleTranscode(ossInputObject,ossOutputObject);
        return JsonData.success(map);
    }


}
